<!DOCTYPE html>
<html lang="zh-CN">
<!--浏览器搞笑标题-->
<script type="text/javascript" src="/js/FunnyTitle.js"></script>






<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/binblog/img/binblog.ico">
  <link rel="icon" type="image/png" href="/binblog/img/binblog.ico">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="">
  <meta name="author" content="leo-bin">
  <meta name="keywords" content="">
  <title>阿斌的个人博客</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_yg9cfy8wd6.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_pjno9b9zyxs.css">


<link  rel="stylesheet" href="/binblog/css/main.css" />

<!-- 自定义样式保持在最底部 -->


<meta name="generator" content="Hexo 4.2.1"></head>


<body>
  <header style="height: 100vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/binblog/">&nbsp;<strong>Abin的Blog</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/binblog/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/binblog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/binblog/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/binblog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/binblog/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="view intro-2" id="background" parallax=true
         style="background: url('/binblog/img/8.webp') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container text-center white-text fadeInUp">
            <span class="h2" id="subtitle">
              
            </span>

            
          </div>

          
            <div class="scroll-down-bar">
              <i class="iconfont icon-arrowdown"></i>
            </div>
          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      <div class="container nopadding-md">
        <div class="py-5" id="board"
          style=margin-top:0>
          
          <div class="container">
            <div class="row">
              <div class="col-12 col-md-10 m-auto">
                


  <div class="row mx-auto index-card">
    
    
      <div class="col-12 col-md-4 m-auto index-img">
        <a href="/binblog/2020/05/31/%E6%89%8B%E5%86%99%E7%B3%BB%E5%88%97%E4%B9%8B%E6%89%8B%E5%86%99%E4%B8%80%E4%B8%AA%E6%A0%88/" target="_self">
          <img src="https://bins-pic.oss-cn-shanghai.aliyuncs.com/mypic/43.jpg" srcset="/binblog/img/loading.gif" alt="手写系列之手写一个栈">
        </a>
      </div>
    
    <div class="col-12 col-md-8 mx-auto index-info">
      <a class="index-header" href="/binblog/2020/05/31/%E6%89%8B%E5%86%99%E7%B3%BB%E5%88%97%E4%B9%8B%E6%89%8B%E5%86%99%E4%B8%80%E4%B8%AA%E6%A0%88/">手写系列之手写一个栈</a>

      <a href="/binblog/2020/05/31/%E6%89%8B%E5%86%99%E7%B3%BB%E5%88%97%E4%B9%8B%E6%89%8B%E5%86%99%E4%B8%80%E4%B8%AA%E6%A0%88/" class="index-excerpt">
        
        
          
        
        <div>手写一个栈
前言
来，手写系列之手写一个栈！
什么是栈
栈的特点就是先进后出，FILO
所有元素都从栈顶进去，从栈顶出去。
就像这样：

如何实现一个栈
根据之前对栈的描述，我们只要需要实现元素是先进后出的特点即可。
大概的思路：
1.首先是选择基本数据容器，这里就直接使用数组了。
2.然后是先进后出，这个其实也很简单
使用一个变量count记录数组中的元素个数，所有元素都直接添加到数组的最后
当</div>
      </a>

      <div class="index-btm post-metas">
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-date"></i>&nbsp;2020-05-31
          </div>
        
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-category"></i>
            
              <a href="/binblog/categories/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">数据结构</a>
            
          </div>
        
        
      </div>
    </div>
  </div>

  <div class="row mx-auto index-card">
    
    
      <div class="col-12 col-md-4 m-auto index-img">
        <a href="/binblog/2020/05/31/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F%E4%B9%8B%E5%8D%95%E4%BE%8B%E6%A8%A1%E5%BC%8F/" target="_self">
          <img src="https://bins-pic.oss-cn-shanghai.aliyuncs.com/mypic/46.jpg" srcset="/binblog/img/loading.gif" alt="设计模式之单例模式">
        </a>
      </div>
    
    <div class="col-12 col-md-8 mx-auto index-info">
      <a class="index-header" href="/binblog/2020/05/31/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F%E4%B9%8B%E5%8D%95%E4%BE%8B%E6%A8%A1%E5%BC%8F/">设计模式之单例模式</a>

      <a href="/binblog/2020/05/31/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F%E4%B9%8B%E5%8D%95%E4%BE%8B%E6%A8%A1%E5%BC%8F/" class="index-excerpt">
        
        
          
        
        <div>设计模式之单例模式前言在软件设计的道路上，出现了一种叫做设计模式的软件设计方法。
可能很多人都觉得我只要会写代码，功能没问题就行。
但是大家有想过你写好的代码的性能，可塑性，可健壮性，可读性吗？
如果说能够用现有知识实现一个功能，这只能说明你是一个合格的程序员。
但是如果还能够对自己写好的代码进行重构，优化，那么！你就还是一个  程序员。。。
说明本次给大家分享最常见的一种设计模式：单例设计模式。</div>
      </a>

      <div class="index-btm post-metas">
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-date"></i>&nbsp;2020-05-31
          </div>
        
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-category"></i>
            
              <a href="/binblog/categories/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/">设计模式</a>
            
          </div>
        
        
      </div>
    </div>
  </div>

  <div class="row mx-auto index-card">
    
    
      <div class="col-12 col-md-4 m-auto index-img">
        <a href="/binblog/2020/05/31/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F%E4%B9%8B%E7%AD%96%E7%95%A5%E6%A8%A1%E5%BC%8F/" target="_self">
          <img src="https://bins-pic.oss-cn-shanghai.aliyuncs.com/mypic/48.jpg" srcset="/binblog/img/loading.gif" alt="设计模式之策略模式">
        </a>
      </div>
    
    <div class="col-12 col-md-8 mx-auto index-info">
      <a class="index-header" href="/binblog/2020/05/31/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F%E4%B9%8B%E7%AD%96%E7%95%A5%E6%A8%A1%E5%BC%8F/">设计模式之策略模式</a>

      <a href="/binblog/2020/05/31/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F%E4%B9%8B%E7%AD%96%E7%95%A5%E6%A8%A1%E5%BC%8F/" class="index-excerpt">
        
        
          
        
        <div>设计模式之策略模式
前话
朋友们，当业务繁忙时，为了加快开发过程，你是否写过垃圾代码？
当你面对的是一堆屎山时，你是不是有过想要打死前任开发者的欲望？
当你想要尽快写完某个业务时，你是否写过诸如下面这种多重if else的嵌套代码？


（这种代码我看了都想打死自己。。。😂）

虽然本人还没经历过上面提到的几种情况，但是我能够体会到你们的艰辛。
本次就给大家分享一种能够大大提高你代码的可读性，扩</div>
      </a>

      <div class="index-btm post-metas">
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-date"></i>&nbsp;2020-05-31
          </div>
        
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-category"></i>
            
              <a href="/binblog/categories/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/">设计模式</a>
            
          </div>
        
        
      </div>
    </div>
  </div>

  <div class="row mx-auto index-card">
    
    
      <div class="col-12 col-md-4 m-auto index-img">
        <a href="/binblog/2020/05/31/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F%E4%B9%8B%E4%BB%A3%E7%90%86%E6%A8%A1%E5%BC%8F/" target="_self">
          <img src="https://bins-pic.oss-cn-shanghai.aliyuncs.com/mypic/47.jpg" srcset="/binblog/img/loading.gif" alt="设计模式之代理模式">
        </a>
      </div>
    
    <div class="col-12 col-md-8 mx-auto index-info">
      <a class="index-header" href="/binblog/2020/05/31/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F%E4%B9%8B%E4%BB%A3%E7%90%86%E6%A8%A1%E5%BC%8F/">设计模式之代理模式</a>

      <a href="/binblog/2020/05/31/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F%E4%B9%8B%E4%BB%A3%E7%90%86%E6%A8%A1%E5%BC%8F/" class="index-excerpt">
        
        
          
        
        <div>设计模式之代理模式前话ok，上次咱们说了单例模式，今天我们来说一说代理模式。
正好复习到Spring和MyBatis了，发现现在但凡是任何一个主流框架的底层，或多或少都用到了代理模式。
比如Spring中的AOP，MyBatis中的Mapper.xml文件和Mapper.java类的映射实现。
看得出来，代理模式的重要性，但是同时，代理模式也是Java中最难以理解的技术之一。
记得刚开始学Java</div>
      </a>

      <div class="index-btm post-metas">
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-date"></i>&nbsp;2020-05-31
          </div>
        
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-category"></i>
            
              <a href="/binblog/categories/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/">设计模式</a>
            
          </div>
        
        
      </div>
    </div>
  </div>

  <div class="row mx-auto index-card">
    
    
      <div class="col-12 col-md-4 m-auto index-img">
        <a href="/binblog/2020/05/31/%E7%BA%AF%E6%89%8B%E5%86%99LRU%E7%AE%97%E6%B3%95%EF%BC%81/" target="_self">
          <img src="https://bins-pic.oss-cn-shanghai.aliyuncs.com/mypic/24.jpg" srcset="/binblog/img/loading.gif" alt="纯手写LRU算法！">
        </a>
      </div>
    
    <div class="col-12 col-md-8 mx-auto index-info">
      <a class="index-header" href="/binblog/2020/05/31/%E7%BA%AF%E6%89%8B%E5%86%99LRU%E7%AE%97%E6%B3%95%EF%BC%81/">纯手写LRU算法！</a>

      <a href="/binblog/2020/05/31/%E7%BA%AF%E6%89%8B%E5%86%99LRU%E7%AE%97%E6%B3%95%EF%BC%81/" class="index-excerpt">
        
        
          
        
        <div>纯手写LRU算法！什么是LRU？1.Latest Recently Unuesd（最近最少未使用）。
2.如果一个数据在最近一段时间内都没有被访问，那么就认为这个数据在以后被访问的概率也很小了。
3.所以当内存满了的时候，这个数据就会最先被淘汰掉。
如何实现？1.最朴素的思想就是用数组+时间戳的方式，不过这样做效率较低。
2.因此，我们可以用双向链表+哈希表（HashMap）实现（链表用来表示位置</div>
      </a>

      <div class="index-btm post-metas">
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-date"></i>&nbsp;2020-05-31
          </div>
        
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-category"></i>
            
              <a href="/binblog/categories/%E7%AE%97%E6%B3%95/">算法</a>
            
          </div>
        
        
      </div>
    </div>
  </div>

  <div class="row mx-auto index-card">
    
    
      <div class="col-12 col-md-4 m-auto index-img">
        <a href="/binblog/2020/05/31/%E5%88%86%E5%B8%83%E5%BC%8F%E5%9C%BA%E6%99%AF%E4%B8%8B%E7%9A%84%E5%85%A8%E5%B1%80%E5%94%AF%E4%B8%80id%E7%94%9F%E6%88%90%E6%96%B9%E6%A1%88/" target="_self">
          <img src="https://bins-pic.oss-cn-shanghai.aliyuncs.com/mypic/23.jpg" srcset="/binblog/img/loading.gif" alt="分布式场景下的全局唯一id生成方案">
        </a>
      </div>
    
    <div class="col-12 col-md-8 mx-auto index-info">
      <a class="index-header" href="/binblog/2020/05/31/%E5%88%86%E5%B8%83%E5%BC%8F%E5%9C%BA%E6%99%AF%E4%B8%8B%E7%9A%84%E5%85%A8%E5%B1%80%E5%94%AF%E4%B8%80id%E7%94%9F%E6%88%90%E6%96%B9%E6%A1%88/">分布式场景下的全局唯一id生成方案</a>

      <a href="/binblog/2020/05/31/%E5%88%86%E5%B8%83%E5%BC%8F%E5%9C%BA%E6%99%AF%E4%B8%8B%E7%9A%84%E5%85%A8%E5%B1%80%E5%94%AF%E4%B8%80id%E7%94%9F%E6%88%90%E6%96%B9%E6%A1%88/" class="index-excerpt">
        
        
          
        
        <div>全局唯一id生成方案背景唯一id是我们在开发系统中不可避免的一个大问题。
诸如登陆业务中需要的sessionId，或者userId，以及消息队列中用到的msgId，还有涉及到金钱利益相关的订单id等等。。。
尤其是分布式系统中，如何生成一个适合具体场景，还要满足各方面的性能的全局唯一id呢?
本文搜寻了网上的一些方案，在这里进行总结。
1.数据库主键自增1）介绍利用数据库主键自增，我们可以将数据插</div>
      </a>

      <div class="index-btm post-metas">
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-date"></i>&nbsp;2020-05-31
          </div>
        
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-category"></i>
            
              <a href="/binblog/categories/%E7%AE%97%E6%B3%95/">算法</a>
            
          </div>
        
        
      </div>
    </div>
  </div>

  <div class="row mx-auto index-card">
    
    
      <div class="col-12 col-md-4 m-auto index-img">
        <a href="/binblog/2020/05/31/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8Java%E8%AE%BE%E8%AE%A1%E4%B8%80%E4%B8%AA%E7%94%9F%E4%BA%A7%E8%80%85%E6%B6%88%E8%B4%B9%E8%80%85/" target="_self">
          <img src="https://bins-pic.oss-cn-shanghai.aliyuncs.com/mypic/2.jpg" srcset="/binblog/img/loading.gif" alt="如何用Java设计一个简单的生产者消费者">
        </a>
      </div>
    
    <div class="col-12 col-md-8 mx-auto index-info">
      <a class="index-header" href="/binblog/2020/05/31/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8Java%E8%AE%BE%E8%AE%A1%E4%B8%80%E4%B8%AA%E7%94%9F%E4%BA%A7%E8%80%85%E6%B6%88%E8%B4%B9%E8%80%85/">如何用Java设计一个简单的生产者消费者</a>

      <a href="/binblog/2020/05/31/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8Java%E8%AE%BE%E8%AE%A1%E4%B8%80%E4%B8%AA%E7%94%9F%E4%BA%A7%E8%80%85%E6%B6%88%E8%B4%B9%E8%80%85/" class="index-excerpt">
        
        
          
        
        <div>生产者消费者
本次给大家分享的是如何使用Java编写一个简易的生产者消费者模板！
【以下都简称生产者消费者模式为PV模式，P叫做生产者，V叫做消费者】
什么是生产者-消费者？
说起生产者和消费者大家其实并不陌生。
早就在学习操作系统的时候我们就知道了如何使用信号量的PV操作来实现进程之间的通信。
PV操作本质上就是生产者消费者模式的核心所在！
PV操作
再说PV操作之前我们有必要引入临界区的概念。</div>
      </a>

      <div class="index-btm post-metas">
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-date"></i>&nbsp;2020-05-31
          </div>
        
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-category"></i>
            
              <a href="/binblog/categories/%E7%AE%97%E6%B3%95/">算法</a>
            
          </div>
        
        
      </div>
    </div>
  </div>

  <div class="row mx-auto index-card">
    
    
      <div class="col-12 col-md-4 m-auto index-img">
        <a href="/binblog/2020/05/30/%E8%AE%BE%E8%AE%A1%E4%B8%80%E4%B8%AA%E6%8A%A2%E7%BA%A2%E5%8C%85%E7%AE%97%E6%B3%95/" target="_self">
          <img src="https://bins-pic.oss-cn-shanghai.aliyuncs.com/mypic/14.jpg" srcset="/binblog/img/loading.gif" alt="如何设计一个抢红包算法">
        </a>
      </div>
    
    <div class="col-12 col-md-8 mx-auto index-info">
      <a class="index-header" href="/binblog/2020/05/30/%E8%AE%BE%E8%AE%A1%E4%B8%80%E4%B8%AA%E6%8A%A2%E7%BA%A2%E5%8C%85%E7%AE%97%E6%B3%95/">如何设计一个抢红包算法</a>

      <a href="/binblog/2020/05/30/%E8%AE%BE%E8%AE%A1%E4%B8%80%E4%B8%AA%E6%8A%A2%E7%BA%A2%E5%8C%85%E7%AE%97%E6%B3%95/" class="index-excerpt">
        
        
          
        
        <div>抢红包算法
你会的越多，你不会的就越多，学无止境呀！

1.背景
自从微信红包上线以来，电子红包这个概念瞬间火遍大江南北
不仅身边的朋友成迷于电子红包，自己的家族群里也是。。。
一到过年，群里也不聊天，就等着抢红包。
怪不得说年味变了呢     ╮(╯▽╰)╭
2.突发奇想电子红包这么火，可是你知道它的设计原理吗？这么多人抢如何保证竞争的公平呢？
假设现在让你去设计一个抢红包的算法，你会怎么设计？</div>
      </a>

      <div class="index-btm post-metas">
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-date"></i>&nbsp;2020-05-30
          </div>
        
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-category"></i>
            
              <a href="/binblog/categories/%E7%AE%97%E6%B3%95/">算法</a>
            
          </div>
        
        
      </div>
    </div>
  </div>

  <div class="row mx-auto index-card">
    
    
      <div class="col-12 col-md-4 m-auto index-img">
        <a href="/binblog/2020/05/30/hello-world/" target="_self">
          <img src="https://bins-pic.oss-cn-shanghai.aliyuncs.com/mypic/v2-68347a731253e08e291a3f43d904b177_r.jpg" srcset="/binblog/img/loading.gif" alt="Hello World">
        </a>
      </div>
    
    <div class="col-12 col-md-8 mx-auto index-info">
      <a class="index-header" href="/binblog/2020/05/30/hello-world/">Hello World</a>

      <a href="/binblog/2020/05/30/hello-world/" class="index-excerpt">
        
        
          
        
        <div>Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
教你怎么用</div>
      </a>

      <div class="index-btm post-metas">
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-date"></i>&nbsp;2020-05-30
          </div>
        
        
          <div class="post-meta mr-3">
            <i class="iconfont icon-category"></i>
            
              <a href="/binblog/categories/%E5%A4%A7%E5%89%8D%E7%AB%AF/">大前端</a>
            
          </div>
        
        
          <div class="post-meta">
            <i class="iconfont icon-tags"></i>
            
              <a href="/binblog/tags/Hexo-Fluid/">-[Hexo,Fluid]</a>
            
          </div>
        
      </div>
    </div>
  </div>



  <nav aria-label="navigation">
    <span class="pagination" id="pagination">
      <a class="extend prev" rel="prev" href="/binblog/page/3/"><i class="iconfont icon-arrowleft"></i></a><a class="page-number" href="/binblog/">1</a><a class="page-number" href="/binblog/page/2/">2</a><a class="page-number" href="/binblog/page/3/">3</a><span class="page-number current">4</span>
    </span>
  </nav>
  
  <script>
    for (ele of document.getElementById("pagination").getElementsByTagName("a")) {
      ele.href += '#board';
    }
  </script>



              </div>
            </div>
          </div>
        </div>
      </div>
    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  

  <footer class="mt-5">
  <div class="text-center py-3">
    <div>
      <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a>
      <i class="iconfont icon-love"></i>
      <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener">
        <span>Fluid</span></a>
    </div>
    
  <div class="statistics">
    
    

    
      
        <!-- LeanCloud 统计PV -->
        <span id="leancloud-site-pv-container" style="display: none">
            总访问量 
            <span id="leancloud-site-pv"></span>
             次
          </span>
      
      
        <!-- LeanCloud 统计UV -->
        <span id="leancloud-site-uv-container" style="display: none">
            总访客数 
            <span id="leancloud-site-uv"></span>
             人
          </span>
      

    
  </div>


    
  <!-- 备案信息 -->
  <div class="beian">
    <a href="http://beian.miit.gov.cn/" target="_blank"
       rel="nofollow noopener">京ICP证123456号</a>
    
      <a
        href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=12345678"
        rel="nofollow noopener"
        class="beian-police"
        target="_blank"
      >
        <span class="beian-police-sep">&nbsp;|&nbsp;</span>
        
          <img src="/binblog/img/police_beian.png" srcset="/binblog/img/loading.gif" alt="police-icon" />
        
        <span>京公网安备12345678号</span>
      </a>
     
  </div>


    
  </div>
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/binblog/js/debouncer.js" ></script>
<script  src="/binblog/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/binblog/js/lazyload.js" ></script>
  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/binblog/js/clipboard-use.js" ></script>



  <script defer>
  (function () {
    // 查询存储的记录
    function getRecord(Counter, target) {
      return new Promise(function (resolve, reject) {
        Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify({target})))
          .then(resp => resp.json())
          .then(({results, code, error}) => {
            if (code === 401) {
              throw error;
            }
            if (results && results.length > 0) {
              var record = results[0];
              resolve(record);
            } else {
              Counter('post', '/classes/Counter', {target, time: 0})
                .then(resp => resp.json())
                .then((record, error) => {
                  if (error) {
                    throw error;
                  }
                  resolve(record);
                }).catch(error => {
                console.error('Failed to create', error);
                reject(error);
              });
            }
          }).catch((error) => {
          console.error('LeanCloud Counter Error:', error);
          reject(error);
        });
      })
    }

    // 发起自增请求
    function increment(Counter, incrArr) {
      return new Promise(function (resolve, reject) {
        Counter('post', '/batch', {
          "requests": incrArr
        }).then((res) => {
          res = res.json();
          if (res.error) {
            throw res.error;
          }
          resolve(res);
        }).catch((error) => {
          console.error('Failed to save visitor count', error);
          reject(error);
        });
      });
    }

    // 构建自增请求体
    function buildIncrement(objectId) {
      return {
        "method": "PUT",
        "path": `/1.1/classes/Counter/${ objectId }`,
        "body": {
          "time": {
            '__op': 'Increment',
            'amount': 1
          }
        }
      }
    }

    // 校验是否为有效的 UV
    function validUV() {
      var key = 'LeanCloud_UV_Flag';
      var flag = localStorage.getItem(key);
      if (flag) {
        // 距离标记小于 24 小时则不计为 UV
        if (new Date().getTime() - parseInt(flag) <= 86400000) {
          return false;
        }
      }
      localStorage.setItem(key, new Date().getTime().toString());
      return true;
    }

    function addCount(Counter) {
      var enableIncr = 'true' === 'true' && window.location.hostname !== 'localhost';
      var getterArr = [];
      var incrArr = [];

      // 请求 PV 并自增
      var pvCtn = document.querySelector('#leancloud-site-pv-container');
      if (pvCtn || enableIncr) {
        var pvGetter = getRecord(Counter, 'site-pv').then((record) => {
          incrArr.push(buildIncrement(record.objectId))
          var ele = document.querySelector('#leancloud-site-pv');
          if (ele) {
            ele.innerText = record.time + 1;
            if (pvCtn) {
              pvCtn.style.display = 'inline';
            }
          }
        });
        getterArr.push(pvGetter);
      }

      // 请求 UV 并自增
      var uvCtn = document.querySelector('#leancloud-site-uv-container');
      if (uvCtn || enableIncr) {
        var uvGetter = getRecord(Counter, 'site-uv').then((record) => {
          var vuv = validUV();
          vuv && incrArr.push(buildIncrement(record.objectId))
          var ele = document.querySelector('#leancloud-site-uv');
          if (ele) {
            ele.innerText = record.time + (vuv ? 1 : 0);
            if (uvCtn) {
              uvCtn.style.display = 'inline';
            }
          }
        });
        getterArr.push(uvGetter);
      }

      // 如果是文章，请求文章的浏览数，并自增
      if ('false' === 'true') {
        var viewCtn = document.querySelector('#leancloud-post-views-container');
        if (viewCtn || enableIncr) {
          var target = decodeURI('/binblog/page/4/index.html');
          var viewGetter = getRecord(Counter, target).then((record) => {
            incrArr.push(buildIncrement(record.objectId))
            if (viewCtn) {
              var ele = document.querySelector('#leancloud-post-views');
              if (ele) {
                ele.innerText = (record.time || 0) + 1;
                viewCtn.style.display = 'inline';
              }
            }
          });
          getterArr.push(viewGetter);
        }
      }

      // 如果启动计数自增，批量发起自增请求
      if (enableIncr) {
        Promise.all(getterArr).then(() => {
          incrArr.length > 0 && increment(Counter, incrArr);
        })
      }
    }

    var app_id = 'vsanVmkaurLHyq2Xey9odo5V-gzGzoHsz'
    var app_key = 'v2hMMe4Mzz3mqpy9jwd7qx8B'
    var server_url = ''

    function fetchData(api_server) {
      var Counter = (method, url, data) => {
        return fetch(`${ api_server }/1.1${ url }`, {
          method,
          headers: {
            'X-LC-Id': app_id,
            'X-LC-Key': app_key,
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data)
        });
      };

      addCount(Counter);
    }

    var api_server = app_id.slice(-9) !== '-MdYXbMMI' ? server_url : `https://${ app_id.slice(0, 8).toLowerCase() }.api.lncldglobal.com`;

    if (api_server) {
      fetchData(api_server);
    } else {
      fetch('https://app-router.leancloud.cn/2/route?appId=' + app_id)
        .then(resp => resp.json())
        .then(({api_server}) => {
          fetchData('https://' + api_server);
        });
    }
  })();
</script>








  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "每天早上醒来你都有两个选择，一是盖上被子继续做你没做完的梦，二是掀开被子去完成你未完成的梦。&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>





  <script  src="/binblog/js/local-search.js" ></script>
  <script>
    var path = "/binblog/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



















  

  

  

  

  

  





<script src="/binblog/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"model":{"jsonPath":"/binblog/live2dw/assets/koharu.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":true},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
